import {
	last
} from 'lodash';
import http from '@/utils/http'

class API {
	static api = new API()

	//聊天记录（私聊）
	async history(days, page, per_page, last_id = 0) {
		let url = "?days=" + days + "&page=" + page;
		if (last_id > 0) {
			url = url + "&last_id=" + last_id
		}
		
		if(per_page){
			url = url + "&per_page=" + per_page
		}

		return await http.get('/ivmcr/member/chats/history' + url, {}, {
			auth: true
		})
	}

	//群聊聊天记录
	async groupHistory(id, page) {
		return await http.get('/ivmcr/member/chats/group_history', {
			id,
			page
		}, {
			auth: true
		})
	}

	//群聊列表
	async groupList(type, page, days) {
		return await http.get('/ivmcr/member/chats/group_list', {
			type,
			page,
			days
		}, {
			auth: true
		})
	}

	//已加入分组群聊列表
	async applyGroupList(page, days) {
		return await http.get('/ivmcr/member/chats/apply_group_list', {
			page,
			days
		}, {
			auth: true
		})
	}

	//未加入 分组群聊列表
	async otherGroupList(days, page) {
		return await http.get('/ivmcr/member/chats/other_group_list', {
			page,
			days
		}, {
			auth: true
		})
	}

	//申请加入群组列表
	async applyGroup(group_id, days) {
		return await http.post('/ivmcr/member/chats/apply', {
			group_id,
			days
		}, {
			auth: true
		})
	}

	//个人信息记录
	async chatCount(days = 0) {
		return await http.get('/ivmcr/member/chat_count', {
			days
		}, {
			auth: true
		})
	}

	//未读消息数
	async readNum(days) {
		return await http.get('/ivmcr/member/chats/readnum', {days}, {
			auth: true
		})
	}

	async getRemind() {
		return await http.get("/ivmcr/member/remind", {}, {
			auth: true
		})
	}

	async getUsertofid(days) {
		return await http.get("/ivmcr/member/getusertofid", {
			days
		}, {
			auth: true
		})
	}

	//已读语音消息
	async readVedio(id) {
		return await http.get("/ivmcr/member/chats/readVedio", {
			id
		}, {
			auth: true
		})
	}
}

export default API.api